package com.maxatime.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.maxatime.pojo.entity.kaoshi;
import com.maxatime.service.Ssbkaoshi2;
import com.maxatime.util.MyContent;

//10月份考试题
@Controller
@RequestMapping("/Ssbkaoshi2")
public class Ssbconteroller2 {
	
	@Autowired
	Ssbkaoshi2 ssbkaoshi2;
	
	@RequestMapping("/cha")
	public String cha() {
		return "Ssbks2/kaoshi";
	}
	/**
	 * 
	 * @Title: que   
	 * @Description: TODO(ssb 2023.10.28 考试项目)   
	 * @param: @param kaoshi
	 * @param: @return      
	 * @return: Map<String,Object>      
	 * @throws   
	 * @author: ssb    
	 * @date:   2023年10月30日 下午2:08:07   
	 * @version V1.0
	 */
	@RequestMapping("/que")
	@ResponseBody
	public Map<String, Object> que(@RequestBody kaoshi kaoshi){
		Map<String, Object > m = new HashMap<>();
		List<kaoshi> list = ssbkaoshi2.listData(kaoshi);
		m.put(MyContent.CODE, "0000");
		m.put(MyContent.MSG, "查询成功");
		m.put(MyContent.DATA, list);
		return m;
	}
		
	// 新增
		@RequestMapping("/save")
		@ResponseBody
		public Map<String, Object> save(@RequestBody kaoshi kaoshi) {
			Map<String, Object> m = new HashMap<>();
			ssbkaoshi2.insertSelective(kaoshi);
			m.put(MyContent.CODE, "1111");
			m.put(MyContent.MSG, "新增成功");
			return m;
		}
		
		// 删除
		@RequestMapping("/del")
		@ResponseBody
		public Map<String, Object> del(@RequestBody String jsonStr) {
			JSONObject jsonObj = JSONObject.parseObject(jsonStr);
			int pkid = jsonObj.getInteger("pkid");
			ssbkaoshi2.deleteByPrimaryKey(pkid);
			Map<String, Object> m = new HashMap<>();
			m.put(MyContent.CODE, "2222");
			m.put(MyContent.MSG, "删除成功");
			return m;
		}
		// 反显
		@RequestMapping("/findpkid")
		@ResponseBody
		public Map<String, Object > findpkid(@RequestBody String jsonStr){
			JSONObject jsonObj = JSONObject.parseObject(jsonStr);
			int pkid = jsonObj.getInteger("pkid");
			kaoshi kaoshi = ssbkaoshi2.findpkid(pkid);
			Map<String, Object> m = new HashMap<>();
			m.put(MyContent.CODE, "3333");
			m.put(MyContent.MSG, "反显成功");
			m.put(MyContent.DATA, kaoshi);
			return m;
		}
		// 修改
		@RequestMapping("/update")
		@ResponseBody
		public Map<String, Object> update(@RequestBody kaoshi kaoshi){
			ssbkaoshi2.update(kaoshi);
			Map<String, Object> m = new HashMap<>();
			m.put(MyContent.CODE, "4444");
			m.put(MyContent.MSG, "修改成功");
			return m;
		}
		
		@RequestMapping("/bzt")
		@ResponseBody
		public Map<String, Object> bzt(@RequestBody kaoshi kaoshi){
			Map<String, Object > m = new HashMap<>();
			List<kaoshi> list = ssbkaoshi2.listData(kaoshi);
			m.put(MyContent.CODE, "0000");
			m.put(MyContent.MSG, "查询成功");
			m.put(MyContent.DATA, list);
			return m;
		}
		
}
